<div class="panel-manage">
	<div class="navbar navbar-inverse">
		<div class="navbar-inner">	
			<div class="text-right">		
		    	<button class="btn btn-primary" id="btn-save">บันทึก</button>
		    </div>	
		</div>
	</div>	
	<div class="panel-message"></div>
	<div style="margin-top:20px;">
		<div class="well well-small"><b>ข้อมูลผู้ใช้</b></div>				
		<form id="frm-personnel" method="post" action="<?php print base_url() . "member/personnel/ajax_save"; ?>">		
			<div class="section">			
				<div class="control-group row-fluid">
					<label class="control-label span4" for="mt">Display Name: </label>
					<div class="controls span8">
						<input type="text" name="mt" id="mt" value="<?php print $item['MEM_TITLE']; ?>" />
					</div>
				</div>
				<div class="control-group row-fluid">
					<label class="control-label span4" for="mbd">วันเกิด: </label>
					<div class="controls span8">						
						<select name="mby" class="input-small">
							<option value="-1"><?php print 'ปี'; ?></option>
						<?php for ($i=1930; $i<=2013; $i++): ?>
							<?php if (date('Y', strtotime($item['MEM_BIRTH_DATE'])) == $i): ?>
									<option value="<?php print $i; ?>" selected><?php print $i; ?></option>
							<?php else: ?>
									<option value="<?php print $i; ?>"><?php print $i; ?></option>
							<?php endif; ?>		
						<?php endfor; ?>
						</select>
												
						<select name="mbm" class="input-medium">
							<option value="-1"><?php print 'เดือน'; ?></option>
						<?php foreach ($months as $key => $value ): ?>
							<?php if (date('m', strtotime($item['MEM_BIRTH_DATE'])) == $key): ?>
								<option value="<?php print $key; ?>" selected><?php print $value; ?></option>
							<?php else: ?>
								<option value="<?php print $key; ?>"><?php print $value; ?></option>
							<?php endif; ?>		
						<?php endforeach; ?>
						</select>
						
						<select name="mbd" class="input-mini">
							<option value="-1"><?php print 'วัน'; ?></option>
						<?php for ($i=1; $i<=31; $i++): ?>
							<?php if (date('d', strtotime($item['MEM_BIRTH_DATE'])) == $i): ?>
								<option value="<?php print str_pad($i, 2, '0', STR_PAD_LEFT); ?>" selected><?php print str_pad($i, 2, '0', STR_PAD_LEFT); ?></option>
							<?php else: ?>
								<option value="<?php print str_pad($i, 2, '0', STR_PAD_LEFT); ?>"><?php print str_pad($i, 2, '0', STR_PAD_LEFT); ?></option>
							<?php endif; ?>		
						<?php endfor; ?>
						</select>
					</div>
				</div>
				<div class="control-group row-fluid">
					<label class="control-label span4" for="mads">ที่อยู่: </label>
					<div class="controls span8">
						<textarea rows="2" class="input-xlarge" name="mads" id="mads"><?php print $item['MEM_ADDRESS']; ?></textarea>
					</div>
				</div>
				<div class="control-group row-fluid">
					<label class="control-label span4" for="mtel">โทรศัพท์: </label>
					<div class="controls span8">
						<input type="text" name="mtel" id="mtel" value="<?php print $item['MEM_TEL']; ?>" />
					</div>
				</div>
				<div class="control-group row-fluid">
					<label class="control-label span4" for="mm">อีเมล: </label>
					<div class="controls span8">
						<input type="text" name="mm" name="mm" value="<?php print $item['MEM_EMAIL']; ?>" placeHolder="name@example.com" />
					</div>
				</div>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript">
	$(function(){
		$('#btn-save').click(function(){
			$('#frm-personnel').ajaxSubmit({
				success:	function(output){
					output = JSON.parse(output);
					
					if (output.result)
						html = '<div class="alert alert-success">';						
					else 
						html = '<div class="alert alert-error">';				
					html += output.message + '</div>';

					$('.panel-message').html(html);
					autoclosealert('.alert', 2000);
				}
			});
		});
	});
</script>